<%@ include file="/html/bjp/seekersprofile/init.jsp" %>

<%
	PortletURL url = renderResponse.createActionURL();
	url.setWindowState(WindowState.NORMAL);
	url.setParameter("struts_action", "/bjp/seekersprofile/process");
	
	Profile profile = null;
	profile = (Profile) request.getAttribute("PROFILE");
	
	String add_url = PortletURLUtil.getCurrent(renderRequest, renderResponse).toString();
	ps.setAttribute("add_url",add_url);
	
	String width = "200px";
		
	String pageTitle = "Basic";
	String tabValue = "Basic";
	
	PortletURL url1 = renderResponse.createRenderURL();
	url1.setWindowState(WindowState.NORMAL);
	url1.setParameter("struts_action", "/bjp/seekersprofile/manage");
	
	if(profile != null) {
	if (Validator.isNotNull(profile) || Validator.isNotNull(profile.getProfileId())) {
		pageTitle = "Basic,Skills";	
	}
	//For tabs action
	
	url1.setParameter("profileId", String.valueOf(profile.getProfileId()));
	url1.setParameter(Constants.CMD, Constants.MANAGE);
	}
	//String add_url = PortletURLUtil.getCurrent(renderRequest, renderResponse).toString();
	//ps.setAttribute("add_url",add_url);
	Calendar dateOfBirth = CalendarFactoryUtil.getCalendar();
	dateOfBirth.set(Calendar.MONTH, Calendar.JANUARY);
	dateOfBirth.set(Calendar.DATE, 1);
	dateOfBirth.set(Calendar.YEAR, 1970);
	
%>
<script type="text/javascript">

jQuery(function() {
	jQuery('#save').click(function() {
		var frm = document.<portlet:namespace />fm;
		frm.<portlet:namespace />cmd.value = "ADD";
		frm.<portlet:namespace />totalExperience.value = 
				frm.<portlet:namespace />expYears.value + "." + frm.<portlet:namespace />expMonths.value;
				frm.submit();
	});
	jQuery('#update').click(function() {
		var frm = document.<portlet:namespace />fm;
		frm.<portlet:namespace />cmd.value = "UPDATE";
		frm.<portlet:namespace />totalExperience.value = 
				frm.<portlet:namespace />expYears.value + "." + frm.<portlet:namespace />expMonths.value;
				frm.submit();
	});
});

</script>
<form name="<portlet:namespace />fm" action=<%= url.toString() %> method="POST" enctype="multipart/form-data">
<input name="<portlet:namespace/>cmd" type="hidden" value="" />
<input name="<portlet:namespace />profileId" type="hidden" value="<%= (Validator.isNull(profile))? "": profile.getProfileId() %>" />
	<table width="100%">
		<tr class="portlet-section-body results-row">
			<td width="30%">
				First Name:
			</td>
			<td width="30%">
				<input type="text" name="firstName" value="<%= (Validator.isNull(profile))? "": profile.getFirstName() %>" style='width:<%= width %>'/>
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Last Name:
			</td>
			<td width="30%">
				<input type="text" name="lastName" value="<%= (Validator.isNull(profile))? "": profile.getLastName() %>" style='width:<%= width %>'/>
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Gender:
			</td>
			<td width="30%">
				Male: <input type="radio"  checked="checked" name="gender" value="1">
				Female: <input type="radio" name="gender" value="2">
			</td>
			<td width="20%">
			</td>
		</tr>
		
		<tr><td colspan='3'><br/></td></tr>
		
		<tr class="results-header">
			<td colspan='3'>Personal Details</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Mobile:
			</td>
			<td width="30%">
				<input type="text" name="mobile" value="<%= (Validator.isNull(profile))? "": profile.getMobile() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Home Phone:
			</td>
			<td width="30%">
				<input type="text" name="homePhone" value="<%= (Validator.isNull(profile))? "": profile.getHomePhone() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Date of birth:
			</td>
			<td width="30%">
			<% if (profile != null) {dateOfBirth.setTime(profile.getDateOfBirth());}%>
				
				<!--<input type="text" name="dateOfBirth" value="<%= (Validator.isNull(profile))? "": profile.getDateOfBirth() %>" style='width:<%= width %>' />-->
				<liferay-ui:input-field model="<%= Profile.class %>" bean="<%= profile %>" field="dateOfBirth"  defaultValue="<%= dateOfBirth %>" />
				
				
				
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Address:
			</td>
			<td width="30%">
				<input type="text" name="address" value="<%= (Validator.isNull(profile))? "": profile.getAddress() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Email:
			</td>
			<td width="30%">
				<input type="text" name="emailAddress" value="<%= (Validator.isNull(profile))? "": profile.getEmailAddress() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Current Location:
			</td>
			<td width="30%">
				<select name="currentLocation" style='width:<%= width %>' />
					<!-- <option value="">-- Select --</option>-->
					<option <%=(Validator.isNull(profile))? "" : (profile.getCurrentLocation().equals("Bangalore")?"selected":"") %> value="Bangalore">Bangalore</option>
					<!-- <option <%=(Validator.isNull(profile))? "" : (profile.getCurrentLocation().equals("Chennai")?"selected":"") %> value="Chennai">Chennai</option>-->				
				</select> 
				<!--<input type="text" name="currentLocation" value="<%= (Validator.isNull(profile))? "": profile.getCurrentLocation() %>" style='width:<%= width %>' />-->
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Job Location:
			</td>
			<td width="30%">
				<select name="jobLocation" style='width:<%= width %>' >
					<!-- <option  value="">-- Select --</option>-->
					<option <%=(Validator.isNull(profile))? "" : (profile.getJobLocation().equals("Bangalore")?"selected":"") %> value="Bangalore">Bangalore</option>
					<!--<option <%=(Validator.isNull(profile))? "" : (profile.getJobLocation().equals("Chennai")?"selected":"") %> value="Chennai">Chennai</option> -->
				</select> 
				<!--<input type="text" name="jobLocation" value="<%= (Validator.isNull(profile))? "": profile.getJobLocation() %>" style='width:<%= width %>' />-->
			</td>
			<td width="20%">
			</td>
		</tr>
		
		<tr><td colspan='3''><br/></td></tr>
		
		<tr class="results-header">
			<td colspan='3''>Profession Details</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Experience:
			</td>
			<td width="30%">
			<% 
			 String ttexp[]=null;
			 if(profile!=null){ttexp= profile.getTotalExperience().split("\\.");}		
			%>
				<select name="<portlet:namespace />expYears" style='width: 80px'>
					
					<% for(int i=0; i < 20; i++) { %>
						<option <%=((Validator.isNull(profile))?"":(Integer.parseInt(ttexp[0])==i?"selected":""))%> value="<%= i %>"><%= i %></option>
					<% } %>
				</select> Years
				<select name="<portlet:namespace />expMonths" style='width: 50px'>
					<% for (int j=0; j<12; j++) { %>
						<option <%=((Validator.isNull(profile))?"":(Integer.parseInt(ttexp[1])==j?"selected":""))%> value="<%= j %>"><%= j %></option>
					<% } %>
				</select> Months
				<input type="hidden" name="<portlet:namespace />totalExperience" value="" />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Job Category:
			</td>
			<td width="30%">
				<input type="text" name="jobCategory" value="<%= (Validator.isNull(profile))? "": profile.getJobCategory() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Key Skills:
			</td>
			<td width="30%">
				<input type="text" name="keySkills" value="<%= (Validator.isNull(profile))? "": profile.getKeySkills() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Highest Qualification:
			</td>
			<td width="30%">
				<input type="text" name="highestQualification" value="<%= (Validator.isNull(profile))? "": profile.getHighestQualification() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Specialization:
			</td>
			<td width="30%">
				<input type="text" name="specialization" value="<%= (Validator.isNull(profile))? "": profile.getSpecialization() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Institute / University:
			</td>
			<td width="30%">
				<input type="text" name="institute" value="<%= (Validator.isNull(profile))? "": profile.getInstitute() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Resume Title:
			</td>
			<td width="30%">
				<input type="text" name="resumeTitle" value="<%= (Validator.isNull(profile))? "": profile.getResumeTitle() %>" style='width:<%= width %>' />
			</td>
			<td width="20%">
			</td>
		</tr>
		
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Upload Resume:
			</td>
			<td width="30%">
				<input type="file" name="resume" />
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row alt">
			<td width="30%">
				Copy/Paste Resume:
			</td>
			<td width="30%">
				<textarea name="<portlet:namespace />up_resume" rows="10" cols="80"><%= (Validator.isNull(profile))? "": profile.getUp_resume() %></textarea>
				
			</td>
			<td width="20%">
			</td>
		</tr>
		<tr class="portlet-section-body results-row">
			<td width="30%">
				Upload Photo:
			</td>
			<td width="30%">
				<input type="file" name="photo" />
			</td>
			<td width="20%">
			</td>
		</tr>
		
		<tr class="portlet-section-body results-row">
			<td colspan="3" align="center">
				<% if (Validator.isNull(profile)) { %>
					<input type="button" value="save" id="save"/>
				<% } else { %>
					<input type="button" value="Update" id="update" />
				<% } %>
			</td>
		</tr>
	</table>
</form>
